<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学习中心 - 多语言旅行助手</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="style-learning.css">
</head>
<body>
    <!-- 顶部导航栏 -->
    <header>
        <h1>多语言旅行助手</h1>
        <nav>
            <ul>
                <li><a href="index.html">首页</a></li>
                <li><a href="learning.html" class="active">学习中心</a></li>
                <li><a href="translation.html">翻译</a></li>
                <li><a href="culture.html">文化知识库</a></li>
                <li><a href="map.html">离线地图</a></li>
                <li><a href="travel-plan.html">旅行计划</a></li>
                <li><a href="offline-content.html">离线内容</a></li>
                <li><a href="profile.html">个人资料</a></li>
                <li><a href="settings.html">设置</a></li>
            </ul>
        </nav>
    </header>

    <!-- 侧边导航栏 -->
    <aside class="side-nav">
        <ul>
            <li>
                <a href="index.html">
                    <img src="images/home.svg" alt="首页图标">
                    <span>首页</span>
                </a>
            </li>
            <li>
                <a href="learning.html" class="active">
                    <img src="images/book-open-bold.svg" alt="学习图标">
                    <span>学习</span>
                </a>
            </li>
            <li>
                <a href="translation.html">
                    <img src="images/vector_25_310.svg" alt="翻译图标">
                    <span>翻译</span>
                </a>
            </li>
            <li>
                <a href="culture.html">
                    <img src="images/globe-bold.svg" alt="文化图标">
                    <span>文化</span>
                </a>
            </li>
            <li>
                <a href="map.html">
                    <img src="images/vector_25_317.svg" alt="地图图标">
                    <span>地图</span>
                </a>
            </li>
            <li>
                <a href="offline-content.html">
                    <img src="images/vector_25_324.svg" alt="离线内容图标">
                    <span>离线</span>
                </a>
            </li>
            <li>
                <a href="settings.html">
                    <img src="images/vector_25_331.svg" alt="设置图标">
                    <span>设置</span>
                </a>
            </li>
        </ul>
    </aside>

    <!-- 内容区 -->
    <main class="content learning-content">
        <h1 class="page-title">学习中心</h1>
        
        <div class="language-selection">
            <h2>选择学习语言</h2>
            <div class="language-tabs">
                <button class="lang-tab active" data-lang="en">英语</button>
                <button class="lang-tab" data-lang="ja">日语</button>
                <button class="lang-tab" data-lang="fr">法语</button>
                <button class="lang-tab" data-lang="de">德语</button>
                <button class="lang-tab" data-lang="es">西班牙语</button>
                <button class="lang-tab" data-lang="it">意大利语</button>
            </div>
        </div>
        
        <div class="learning-modules">
            <div class="learning-module">
                <div class="module-header">
                    <h3>情境对话练习</h3>
                    <span class="difficulty-badge beginner">初级</span>
                </div>
                <div class="module-content">
                    <p>通过模拟真实场景的对话练习提高语言应用能力</p>
                    <div class="scenario-list">
                        <div class="scenario-item" data-scenario="restaurant">
                            <img src="images/placeholder.svg" alt="餐厅场景">
                            <span>餐厅点餐</span>
                        </div>
                        <div class="scenario-item" data-scenario="hotel">
                            <img src="images/placeholder.svg" alt="酒店场景">
                            <span>酒店入住</span>
                        </div>
                        <div class="scenario-item" data-scenario="transport">
                            <img src="images/placeholder.svg" alt="交通场景">
                            <span>交通出行</span>
                        </div>
                        <div class="scenario-item" data-scenario="shopping">
                            <img src="images/placeholder.svg" alt="购物场景">
                            <span>购物讨价</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="learning-module">
                <div class="module-header">
                    <h3>常用短语</h3>
                    <span class="difficulty-badge intermediate">中级</span>
                </div>
                <div class="module-content">
                    <p>学习旅行中最常用的表达和短语</p>
                    <div class="phrase-categories">
                        <button class="phrase-category active" data-category="greetings">问候语</button>
                        <button class="phrase-category" data-category="directions">方向指引</button>
                        <button class="phrase-category" data-category="emergency">紧急情况</button>
                        <button class="phrase-category" data-category="shopping">购物用语</button>
                    </div>
                    <div class="phrase-list">
                        <div class="phrase-item">
                            <div class="phrase-original">Hello, how are you?</div>
                            <div class="phrase-translation">你好，你好吗？</div>
                            <button class="phrase-audio-btn">
                                <img src="images/placeholder.svg" alt="播放" width="16" height="16">
                            </button>
                        </div>
                        <div class="phrase-item">
                            <div class="phrase-original">Nice to meet you.</div>
                            <div class="phrase-translation">很高兴认识你。</div>
                            <button class="phrase-audio-btn">
                                <img src="images/placeholder.svg" alt="播放" width="16" height="16">
                            </button>
                        </div>
                        <div class="phrase-item">
                            <div class="phrase-original">Excuse me, where is the bathroom?</div>
                            <div class="phrase-translation">打扰一下，洗手间在哪里？</div>
                            <button class="phrase-audio-btn">
                                <img src="images/placeholder.svg" alt="播放" width="16" height="16">
                            </button>
                        </div>
                        <div class="phrase-item">
                            <div class="phrase-original">How much does this cost?</div>
                            <div class="phrase-translation">这个多少钱？</div>
                            <button class="phrase-audio-btn">
                                <img src="images/placeholder.svg" alt="播放" width="16" height="16">
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="learning-module">
                <div class="module-header">
                    <h3>文化知识问答</h3>
                    <span class="difficulty-badge advanced">高级</span>
                </div>
                <div class="module-content">
                    <p>通过有趣的问答游戏了解目的地文化</p>
                    <button id="start-quiz" class="primary-btn">开始问答</button>
                </div>
            </div>
        </div>
        
        <div class="learning-progress">
            <h2>学习进度</h2>
            <div class="progress-stats">
                <div class="progress-stat">
                    <div class="stat-value">12</div>
                    <div class="stat-label">已学习短语</div>
                </div>
                <div class="progress-stat">
                    <div class="stat-value">3</div>
                    <div class="stat-label">完成对话</div>
                </div>
                <div class="progress-stat">
                    <div class="stat-value">5</div>
                    <div class="stat-label">学习天数</div>
                </div>
            </div>
            <div class="progress-bar-container">
                <div class="progress-label">
                    <span>总体进度</span>
                    <span>25%</span>
                </div>
                <div class="progress-bar">
                    <div class="progress-fill" style="width: 25%;"></div>
                </div>
            </div>
        </div>
    </main>

    <!-- 对话练习模态框 -->
    <div id="dialog-modal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2>餐厅点餐对话</h2>
                <button class="close-modal">&times;</button>
            </div>
            <div class="modal-body">
                <div class="dialog-container">
                    <div class="dialog-message other">
                        <div class="message-content">Hello, welcome to our restaurant. Do you have a reservation?</div>
                        <button class="audio-btn">
                            <img src="images/placeholder.svg" alt="播放" width="16" height="16">
                        </button>
                    </div>
                    
                    <div class="dialog-options">
                        <p>如何回应?</p>
                        <button class="dialog-option">Yes, I have a reservation for 7pm.</button>
                        <button class="dialog-option">No, but do you have a table available?</button>
                        <button class="dialog-option">I don't understand.</button>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="secondary-btn">退出练习</button>
                <div class="dialog-progress">
                    <span>1/8</span>
                </div>
            </div>
        </div>
    </div>

    <footer>
        <p>&copy; 2025 多语言旅行助手 | 版本 1.0</p>
    </footer>

    <script src="script.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 语言选择标签
            const langTabs = document.querySelectorAll('.lang-tab');
            langTabs.forEach(tab => {
                tab.addEventListener('click', () => {
                    langTabs.forEach(t => t.classList.remove('active'));
                    tab.classList.add('active');
                    loadLanguageContent(tab.dataset.lang);
                });
            });
            
            // 情境对话场景选择
            const scenarioItems = document.querySelectorAll('.scenario-item');
            scenarioItems.forEach(item => {
                item.addEventListener('click', () => {
                    const scenario = item.dataset.scenario;
                    openDialogModal(scenario);
                });
            });
            
            // 短语类别选择
            const phraseCategories = document.querySelectorAll('.phrase-category');
            phraseCategories.forEach(category => {
                category.addEventListener('click', () => {
                    phraseCategories.forEach(c => c.classList.remove('active'));
                    category.classList.add('active');
                    loadPhrases(category.dataset.category);
                });
            });
            
            // 短语发音按钮
            const phraseAudioBtns = document.querySelectorAll('.phrase-audio-btn');
            phraseAudioBtns.forEach(btn => {
                btn.addEventListener('click', () => {
                    const phrase = btn.parentElement.querySelector('.phrase-original').textContent;
                    speakText(phrase, 'en');
                });
            });
            
            // 开始问答按钮
            document.getElementById('start-quiz').addEventListener('click', () => {
                alert('文化知识问答功能即将上线，敬请期待！');
            });
            
            // 对话模态框
            const dialogModal = document.getElementById('dialog-modal');
            const closeModal = document.querySelector('.close-modal');
            const exitBtn = document.querySelector('.modal-footer .secondary-btn');
            
            closeModal.addEventListener('click', () => {
                dialogModal.style.display = 'none';
            });
            
            exitBtn.addEventListener('click', () => {
                dialogModal.style.display = 'none';
            });
            
            window.addEventListener('click', (e) => {
                if (e.target === dialogModal) {
                    dialogModal.style.display = 'none';
                }
            });
            
            // 对话选项
            const dialogOptions = document.querySelectorAll('.dialog-option');
            dialogOptions.forEach(option => {
                option.addEventListener('click', () => {
                    // 模拟对话进行
                    const dialogContainer = document.querySelector('.dialog-container');
                    
                    // 添加用户回应
                    const userMessage = document.createElement('div');
                    userMessage.className = 'dialog-message user';
                    userMessage.innerHTML = `
                        <div class="message-content">${option.textContent}</div>
                        <button class="audio-btn">
                            <img src="images/placeholder.svg" alt="播放" width="16" height="16">
                        </button>
                    `;
                    dialogContainer.appendChild(userMessage);
                    
                    // 隐藏选项
                    document.querySelector('.dialog-options').style.display = 'none';
                    
                    // 模拟加载下一个回应
                    setTimeout(() => {
                        const nextMessage = document.createElement('div');
                        nextMessage.className = 'dialog-message other';
                        nextMessage.innerHTML = `
                            <div class="message-content">Great! Your table is ready. Please follow me.</div>
                            <button class="audio-btn">
                                <img src="images/placeholder.svg" alt="播放" width="16" height="16">
                            </button>
                        `;
                        dialogContainer.appendChild(nextMessage);
                        
                        // 更新进度
                        document.querySelector('.dialog-progress span').textContent = '2/8';
                        
                        // 显示新选项
                        setTimeout(() => {
                            const newOptions = document.createElement('div');
                            newOptions.className = 'dialog-options';
                            newOptions.innerHTML = `
                                <p>如何回应?</p>
                                <button class="dialog-option">Thank you.</button>
                                <button class="dialog-option">Can we have a window seat?</button>
                                <button class="dialog-option">Is the menu available in English?</button>
                            `;
                            dialogContainer.appendChild(newOptions);
                            
                            // 为新选项添加事件
                            newOptions.querySelectorAll('.dialog-option').forEach(newOption => {
                                newOption.addEventListener('click', () => {
                                    alert('对话练习将在完整版中继续...');
                                });
                            });
                        }, 1000);
                    }, 1000);
                });
            });
            
            // 音频播放按钮
            document.querySelectorAll('.audio-btn').forEach(btn => {
                btn.addEventListener('click', () => {
                    const text = btn.parentElement.querySelector('.message-content').textContent;
                    speakText(text, 'en');
                });
            });
        });
        
        // 加载语言内容
        function loadLanguageContent(lang) {
            console.log(`加载${lang}语言内容`);
            // 实际应用中应该从API获取对应语言的学习内容
        }
        
        // 加载短语
        function loadPhrases(category) {
            console.log(`加载${category}类别的短语`);
            // 实际应用中应该从API获取对应类别的短语
        }
        
        // 打开对话模态框
        function openDialogModal(scenario) {
            const modal = document.getElementById('dialog-modal');
            const modalTitle = modal.querySelector('.modal-header h2');
            
            // 设置标题
            switch(scenario) {
                case 'restaurant':
                    modalTitle.textContent = '餐厅点餐对话';
                    break;
                case 'hotel':
                    modalTitle.textContent = '酒店入住对话';
                    break;
                case 'transport':
                    modalTitle.textContent = '交通出行对话';
                    break;
                case 'shopping':
                    modalTitle.textContent = '购物讨价对话';
                    break;
            }
            
            // 重置对话内容
            const dialogContainer = document.querySelector('.dialog-container');
            dialogContainer.innerHTML = `
                <div class="dialog-message other">
                    <div class="message-content">Hello, welcome to our restaurant. Do you have a reservation?</div>
                    <button class="audio-btn">
                        <img src="images/placeholder.svg" alt="播放" width="16" height="16">
                    </button>
                </div>
                
                <div class="dialog-options">
                    <p>如何回应?</p>
                    <button class="dialog-option">Yes, I have a reservation for 7pm.</button>
                    <button class="dialog-option">No, but do you have a table available?</button>
                    <button class="dialog-option">I don't understand.</button>
                </div>
            `;
            
            // 重置进度
            document.querySelector('.dialog-progress span').textContent = '1/8';
            
            // 显示模态框
            modal.style.display = 'block';
            
            // 为新生成的元素添加事件
            document.querySelectorAll('.dialog-option').forEach(option => {
                option.addEventListener('click', handleDialogOption);
            });
            
            document.querySelectorAll('.audio-btn').forEach(btn => {
                btn.addEventListener('click', () => {
                    const text = btn.parentElement.querySelector('.message-content').textContent;
                    speakText(text, 'en');
                });
            });
        }
        
        // 处理对话选项点击
        function handleDialogOption() {
            // 这里的实现与上面的匿名函数相同
            // 实际应用中应该有更完整的对话流程处理
            alert('对话练习将在完整版中继续...');
        }
        
        // 文本朗读
        function speakText(text, lang) {
            if ('speechSynthesis' in window) {
                const utterance = new SpeechSynthesisUtterance(text);
                utterance.lang = lang === 'en' ? 'en-US' : lang;
                window.speechSynthesis.speak(utterance);
            } else {
                console.log('浏览器不支持语音合成');
            }
        }
    </script>
</body>
</html>